package cn.doit.scala.day03

import scala.io.Source

/**
 * @DATE 2021/12/27/15:53
 * @Author MDK
 * @Version 2021.2.2
 * */
object C09_Flatten02 {
  def main(args: Array[String]): Unit = {
    val lines: Iterator[String] = Source.fromFile("d://aaa//1.txt").getLines()
    val res: Iterator[Array[String]] = lines.map(line => line.split("\\s+"))
    val words: List[String] = res.toList.flatten
    val mp: Map[String, List[String]] = words.groupBy(e => e)
    val res2 = mp.map(tp => (tp._1, tp._2.length))
    res2.foreach(println)
  }
}
